<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.gosophia.springsecurity.UserDetailsImpl"%>
<%@page import="org.springframework.security.context.SecurityContextHolder"%>
<%@page import="org.apache.struts2.ServletActionContext,com.gosophia.govDoc.dto.TransientDocumentDTO,com.gosophia.govDoc.dto.DocumentJobDataDTO,com.gosophia.govDoc.dto.DocumentTaskDTO"%>
<%@page import="org.apache.struts2.ServletActionContext"%>
<%
  UserDetailsImpl userDetailsImpl = ((UserDetailsImpl)SecurityContextHolder.getContext().getAuthentication().getPrincipal());
  String jobId = request.getParameter("jobId");
  String userName =(String)userDetailsImpl.getUserAccountDTO().getUserInfoDTO().getUserName();
  Long userAccountId =(Long)userDetailsImpl.getUserAccountDTO().getUserAccountId();
  Long userInfoId = (Long)userDetailsImpl.getUserAccountDTO().getUserInfoDTO().getUserInfoId();
  
  //自动获取OfficeServer和OCX文件完整URL路径
  String mHttpUrlName=request.getRequestURI();
  String mScriptName=request.getServletPath();
  String mServerName="OfficeServer";

  String mServerUrl = "http://"+request.getServerName()+":" + request.getServerPort()+ mHttpUrlName.substring(0,mHttpUrlName.lastIndexOf(mScriptName)) + "/" +mServerName;//取得OfficeServer文件的完整URL
  String mHttpUrl   = "http://"+request.getServerName()+":"+request.getServerPort()+mHttpUrlName.substring(0,mHttpUrlName.lastIndexOf(mScriptName))+"/";
  HttpServletRequest request1 = ServletActionContext.getRequest();
  
  String mEditType ="1,1";//默认为可编辑
  String mShowType="1";//设置载入文档后的界面模式：1文字批注；2手写批注；0文档核稿。
  String mShowMenu="1";//默认显示office菜单
  String mRecordID=null;
  String mFileVersion=null;
  String mShowToolBar="1";
  boolean pluginFocusActive=true;
  if(request1.getAttribute("onlinePath") != null){
	  mRecordID = (String)request1.getAttribute("onlinePath");
  }
  if(request1.getAttribute("onlineVersion") != null){
	  mFileVersion = (String)request1.getAttribute("onlineVersion");
  }
   
   if(request1.getAttribute("onlineIsEdit")!=null){
        mEditType ="0,0";//((String)request1.getAttribute("editType"));//读取editType
        mShowType="1";//不可编辑
       mShowMenu="0";//不显示office菜单
        mShowToolBar="2";
        pluginFocusActive=false;//控件失去焦点
   }
   
  System.out.println("getInfoFromSession.jsp输出文档的uuid：mRecordId:=>"+mRecordID+"  userName:"+userName+"  编辑模式"+ mEditType+" 文档版本："+mFileVersion);
   if(mRecordID==null)mRecordID="";
   if(mFileVersion==null) mFileVersion="";
   %>  

<script type="text/javascript">
    var jobId = "<%=jobId%>";
   
    var userAccountId = "<%=userAccountId%>";
    var userInfoId = "<%=userInfoId%>";

    var mServerUrl = "<%=mServerUrl%>";//weboffice插件服务器交互url地址
    var mHttpUrl = "<%=mHttpUrl%>";
    var mRecordID ="<%=mRecordID%>"
    var mUserName = "<%=userName%>";
    var mFileVersion="<%=mFileVersion%>" ;
    var mEditType="<%=mEditType%>";//设定编辑模式。设定为可编辑，无痕迹，可批注
                         //文档编辑类型  第一位可以为0,1,2,3 其中:0不可编辑;1可以编辑,无痕迹;2可以编辑,有痕迹,不能修订;3可以编辑,有痕迹,能修订；
                         //第二位可以为0,1 其中:0不可批注,1可以批注。可以参考iWebOffice2009的EditType属性，详细参考技术白皮书
      //设定显示模式
    var mShowType="<%=mShowType%>";//文档显示方式  1:表示文字批注  2:表示手写批注  0:表示文档核稿
    var mShowMenu="<%=mShowMenu%>";//菜单显示 1：显示office菜单 0：表示不显示office菜单
    var mShowToolBar="<%=mShowToolBar%>"
   //设定文档类型
    var mFileType=".doc";// 默认为.doc文档           
    var pluginFocusActive="<%=pluginFocusActive%>"        
    
</script>